//引包
var express = require('express')
var path = require('path')
var bodyParser = require('body-parser')
//实例化express；
var app = express();

var router = require('./routers')

//让当前登录状态记住类似 cookie（记住密码）
//通过request.session来访问
var session = require('express-session')

//配置：在express 使用 art-template 模板引擎
app.engine('html',require('express-art-template'))


//开放资源
/* app.use('/modeles/',express.static('./modeles/')) */
app.use('/img/',express.static('./img/'))
/* app.use('/public/',express.static('./public/')) */
app.use('/public/',express.static(path.join(__dirname,'./public/')))
app.use('/node_modules/',express.static('./node_modules/'))

//配置post请求体
app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())

//配置expressSession
//通过request.session来访问
//添加request.session.foo = 'bar'
//访问request.session.foo
app.use(session({
	secret:'keyboard cat',
	resave:false,
	saveUninitialized:true
}))

app.use(router)

app.listen(3000,function(){
	console.log('running.....')
})

